In computer science, memory is allocated from a large pool of unused memory space called the heap. For efficiency, the heap is managed by way of different processes. The garbage collection process is a form of automatic memory management widely used in managed runtime systems, such as Java Virtual Machine (JVM) and Common Language Runtime (CLR).
A logic code (e.g., a garbage collector) is generally executed to reclaim memory that is no longer being used (i.e., garbage). A modern, high performance garbage collector usually manages large objects separately from other objects. Large objects refer to those objects that are bigger in size than a threshold value. For large objects, the overhead of moving/copying in memory is high. Some garbage collectors use a separate memory space (e.g., a managed memory region called large object space or LOS) for storing large objects. A garbage collector may manage the LOS with non-moving garbage collection algorithms (e.g., mark-sweep, tread-mill, etc.).
On the other hand, a non-LOS portion of the heap may be managed by a moving/copying garbage collection algorithm (e.g., semi-space, sliding-compaction, etc.) that has a better performance for non-large objects than a non-moving counterpart. In this way, a single garbage collector can achieve both of the advantages of copying and non-copying garbage collectors simultaneously in one system. The garbage collection design with LOS and non-LOS partitions the heap into two spaces for large objects and non-large objects respectively.
A garbage collector may also place objects into a pinned (i.e., not moveable) space separated from the space for moveable objects. Alternatively, a garbage collector may allocate a special storage space for immortal objects (i.e., objects that are always live during the application's execution time).
Accordingly, multi-space garbage collectors can be classified into two categories. In the first category, the garbage collector only allocates objects in one space (e.g., in a generational garbage collector the objects are only allocated in young object space). In the second category, objects are allocated to more than one space (e.g., garbage collectors with LOS/non-LOS spaces, or pinned/unpinned spaces, or immortal/mortal spaces).
Because the objects' size distributions vary from one application to another and even from one execution phase to the next within one application, it is impossible to statically predefine a proper heap partitioning for LOS and non-LOS in the garbage collection schemes with multiple spaces. Thus, the current, LOS garbage collectors suffer from a problem which occurs when the two spaces don't fit well with the dynamic variations of object size distribution at runtime. This problem leads to unbalanced storage space utilization and negatively impacts the overall efficiency of the garbage collection process.
Systems and methods are needed to improve upon the current garbage collection schemes to achieve maximum garbage collection efficiency.
Features, elements, and aspects of the invention that are referenced by the same numerals in different figures represent the same, equivalent, or similar features, elements, or aspects, in accordance with one or more embodiments.